//package com.atguigu.gulimall.order.config;
//
//import com.zaxxer.hikari.HikariDataSource;
//import io.seata.rm.datasource.DataSourceProxy;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.util.StringUtils;
//
//import javax.sql.DataSource;
//
///**
// * @author 满超
// * @date 2020/06/29
// **/
//@Configuration
//public class MySeataConfig {
//
//    /**
//     * 分布式事务seata代理数据源
//     */
//    @Autowired
//    DataSourceProperties dataSourceProperties;
//
//    @Bean
//    public DataSource dataSource(DataSourceProperties dataSourceProperties) {
//        HikariDataSource hikariDataSource = dataSourceProperties.initializeDataSourceBuilder().type(HikariDataSource.class).build();
//        if (StringUtils.hasText(dataSourceProperties.getName())) {
//            hikariDataSource.setPoolName(dataSourceProperties.getName());
//        }
//        return new DataSourceProxy(hikariDataSource);
//    }
//
//    //@Bean
//    //public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
//    //    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
//    //    sqlSessionFactoryBean.setDataSource(new DataSourceProxy(dataSource));
//    //    return sqlSessionFactoryBean.getObject();
//    //}
//}
